<?php
/*
    OpenLib
    Copyright (C) 2011  Michael Gukov, Pham Thi Thuy Duong

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


namespace Sun;

class Request {
    public $u;
    public $data;

    public $u_str;
    public $method;
    public $method_u;
    public $referer;
    //public $old_req;

    public function __construct() {
        //@$this->old_req = $_SESSION['REQUEST'];
        //$_SESSION['REQUEST'] = $this;

        $this->method = $_SERVER['REQUEST_METHOD'];
        @$this->referer = $_SERVER['HTTP_REFERER'];

        if ($this->method == "POST") $this->data = &$_POST;
        else $this->data = $_GET;

        if (isset($_POST['u'])) {
            $this->method_u = "POST";
            $this->u_str = &$_POST['u'];
        } else if (isset($_GET['u'])) {
            $this->method_u = "GET";
            $this->u_str = &$_GET['u'];
        }
        $this->u = (trim($this->u_str) == "")
            ? array() : explode("/", $this->u_str) ;
    }
}